﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace BitcoinMarket.ViewModels
{
    public class AppSettingsNetworkStatusItemsViewModel : INotifyPropertyChanged
    {
        private AppNetworkStatusChartSettings settings = new AppNetworkStatusChartSettings();

        private string _chartTitle;
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public string ChartTitle
        {
            get
            {
                return _chartTitle;
            }
            set
            {
                if (value != _chartTitle)
                {
                    _chartTitle = value;
                    NotifyPropertyChanged("ChartTitle");
                }
            }
        }

        private string _chartDescription;
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public string ChartDescription
        {
            get
            {
                return _chartDescription;
            }
            set
            {
                if (value != _chartDescription)
                {
                    _chartDescription = value;
                    NotifyPropertyChanged("ChartDescription");
                }
            }
        }

        private string _chartKey;
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public string ChartKey
        {
            get
            {
                return _chartKey;
            }
            set
            {
                if (value != _chartKey)
                {
                    _chartKey = value;
                    NotifyPropertyChanged("ChartKey");
                }
            }
        }

        private bool _chartEnabledDefault;
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public bool ChartEnabledDefault
        {
            get
            {
                return _chartEnabledDefault;
            }
            set
            {
                if (value != _chartEnabledDefault)
                {
                    _chartEnabledDefault = value;
                    NotifyPropertyChanged("ChartEnabledDefault");
                }
            }
        }

        private bool _chartEnabled;
        /// <summary>
        /// Sample ViewModel property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public bool ChartEnabled
        {
            get
            {
                _chartEnabled = settings.GetValueOrDefault<bool>(this.ChartKey, this.ChartEnabledDefault);
                
                return _chartEnabled;
            }
            set
            {
                if (value != _chartEnabled)
                {
                    _chartEnabled = value;
                    //save the setting
                    settings.AddOrUpdateValue(this.ChartKey, value);

                    NotifyPropertyChanged("ChartEnabled");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
